/**
 * Created by hjqi on 2016/3/3.
 */

angular.module('NatureCloud').factory('dockerRegisterService', function ($http,registryVersion) {
    return {
        getTagFromRegistry:function(imgUrl){
            var getTagURL = "/api/listTag?imageurl=" ;

            if( registryVersion){
                getTagURL =registryVersion.getTagURL  ;
            }
            return $http.get( (getTagURL+ imgUrl));
        },
        getImages: function(isMarket){
            var URL = "/api/listImgV2?isMarket=" ;
            if(registryVersion){
                URL = registryVersion.getImagesURL ;
            }
            return $http.get( URL+ isMarket );
        },
        getImageInfo:function(imageItem){
            var _url = '/api/listImg?isMarket='
            if(registryVersion){
                _url = registryVersion.getImageInfoURL ;
            }
            _url += imageItem.isMarket;
            _url += "&requestimage=" + imageItem.name;
            return $http.get(_url);
        },
        deleteImage:function(data){
            var serviceUrRL = '/api/deleteImagedeleteImage' ;
            if( registryVersion ){
                serviceUrRL = registryVersion.deleteImage ;
            }
            var req = {
                method: 'DELETE',
                url: serviceUrRL,
                headers: {
                    'Content-Type': 'application/json'
                },
                data:data
            };
            return  $http(req).then(function (response) {
                return response.data;
            });

        }
    };
});

